/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PaisesOcupados.java
 *
 * Created on 24-sep-2011, 22:53:57
 */
package tsb_tp2.vista;

import javax.swing.DefaultListModel;
import tsb_tp1.LinkedList;
import tsb_tp2.Dominio.PaisOcupado;

/**
 *
 * @author Burgos
 */
public class PaisesOcupados extends javax.swing.JDialog {

   DefaultListModel modeloLista;
   Principal parent;
    public PaisesOcupados(java.awt.Frame parent, boolean modal) {
        super(parent,modal);
        initComponents();
           this.parent=(Principal) parent;
            modeloLista= new DefaultListModel();
         listaPaisesOcupados.setModel(modeloLista);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        listaPaisesOcupados = new javax.swing.JList();
        btnCancelar = new javax.swing.JButton();

        setMinimumSize(new java.awt.Dimension(300, 400));

        listaPaisesOcupados.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(listaPaisesOcupados);

        btnCancelar.setText("Cancelar");
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 256, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGroup(layout.createSequentialGroup()
                .addGap(74, 74, 74)
                .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnCancelar)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
this.dispose();
}//GEN-LAST:event_btnCancelarActionPerformed
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {

LinkedList lista= this.parent.getJuego().obtenerListadoDePaisesOcupados().size()>0?this.parent.getJuego().obtenerListadoDePaisesOcupados():new LinkedList();

for(int i=0;i<lista.size();i++){
modeloLista.addElement((PaisOcupado)lista.get(i));
}

}

private void formWindowLostFocus(java.awt.event.WindowEvent evt) {
modeloLista.clear();
}

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JList listaPaisesOcupados;
    // End of variables declaration//GEN-END:variables
}
